package com.rxyl.love.petdoctor.acticity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.PopupMenu;
import android.widget.Toast;

import com.rxyl.love.petdoctor.R;
import com.rxyl.love.petdoctor.util.DataClearUtils;
import com.rxyl.love.petdoctor.view.SwitchView;

public class SettingActivity extends AppCompatActivity {
    private SwitchView switchView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        switchView = (SwitchView) findViewById(R.id.switchView_setting);
        switchView.setOnStateChangedListener(new SwitchView.OnStateChangedListener() {
            @Override
            public void OnStateChanged(boolean isOn) {
                if(isOn){
                    Toast.makeText(SettingActivity.this, "打开", Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(SettingActivity.this, "关闭", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    //清除缓存
    public void cleanCache(View view) {
        AlertDialog.Builder builder = new AlertDialog.Builder(SettingActivity.this);
        builder.setMessage("确认删除缓存吗?");
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        DataClearUtils.cleadInternalCache();
                    }
                }
        );
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.show();

    }
}
